
import java.util.ArrayList;
import processing.core.*;

/**
 *
 * @author admindev
 */
public class Base extends Player
{
    private int x = 200;
    private int y = 400;
    private int height = 125;
    private int width = 125;
    
    private PImage image;
    private String nameImage = "base_terran.png";
    
    private int xCase1 = 290;
    private int yCase1 = 610;
    private int heightCase1 = 65;
    private int widthCase1 = 65;
    private PImage logoCase1;
    private String PngCase1 = "ImageHub/crystal_up.png";
    
    private ArrayList tabProcessBar = new ArrayList();
    
    ////////////////////////////////////////////////////////////////////////
    ////////                     Constructor                        ////////
    ///////////////////////////////////////////////////////////////////////
   
    public Base(Jeu app)
    {
        super(app);
    }
     
    ////////////////////////////////////////////////////////////////////////
    ////////                     Fonction                           ////////
    ///////////////////////////////////////////////////////////////////////
    
    
    /**
     * Affiche l'image de la Base
     */
    public void display()
    {
        program.image(getImage(),x ,y ,height ,width );
    }

    
    public boolean process(float mouseX, float mouseY)
    {
        if(onCase1(mouseX ,mouseY))
        {
            if(crystals >= getCostCase1())
            {
                return true;
            }
        }
        return false; 
    }
    
    /**
     * Verifie si la position de X et Y correspond a la position de la Base.
     * 
     * @param mouseX
     * @param mouseY
     * @return true,false
     */
    public boolean onPosition(float mouseX ,float mouseY)
    {
        if( mouseX > x && mouseX < x+width && mouseY > y && mouseY < y+height )
            return true;
        else
            return false;
    }
    
    /**
     * Verifie si la position de X et Y correspond a la position de la 1ere case du hud.
     * 
     * @param mouseX
     * @param mouseY
     * @return true,false
     */
    public boolean onCase1(float mouseX ,float mouseY)
    {
        if( mouseX > xCase1 && mouseX < xCase1+widthCase1 && mouseY > yCase1 && mouseY < yCase1+heightCase1 )
            return true;
        else
            return false;
    }
    
    public int getCostCase1()
    {
        switch (lvlCrystals)
        {    
            case 0:
                return 0;
            case 1:
                return 500;
            case 2:
                return 800;
            case 3:
                return 1500;
            case 4:
                return 1800;
            case 5:
                return 2000;
            default:
                return 500;
        }
    }
    
    public void displayProcessBar()
    {
        logoCase1 = program.loadImage(PngCase1);
        program.image(logoCase1, xCase1, yCase1,heightCase1,widthCase1);
        
        //program.image(logoCase2, xCase2, yCase2,heightCase2,widthCase2);
        //program.image(logoCase3, xCase3, yCase3,heightCase3,widthCase3);
        //program.image(logoCase4, xCase4, yCase4,heightCase4,widthCase4);
    }
    
    ////////////////////////////////////////////////////////////////////////
    ////////                     Getter/ Setter                     ////////
    ///////////////////////////////////////////////////////////////////////
    
    public PImage getImage()
    {
        if(image == null)
        {
            image = program.loadImage(nameImage);
        }
        return image;
    }
    
    public int getY()
    {
        return y;
    }

    public void setY(int y)
    {
        this.y = y;
    }

    public int getX()
    {
        return x;
    }

    public void setX(int x)
    {
        this.x = x;
    }

    public int getHeight()
    {
        return height;
    }

    public void setHeight(int height)
    {
        this.height = height;
    }

    public int getWidth()
    {
        return width;
    }

    public void setWidth(int width)
    {
        this.width = width;
    }
    
    public String getNameImage()
    {
        return nameImage;
    }

}
